/* CodeBuilder代码生成器 创建时间：2011-11-08 00:25:20 */
using System;
using System.Data;
using System.Collections.Generic;
using Maticsoft.Common;

namespace BLL
{
	/// <summary>
	/// SpaceCode
	/// </summary>
	public partial class SpaceCode
	{
		private readonly DAL.SpaceCode dal=new DAL.SpaceCode();
		public SpaceCode()
		{}
		#region  Method

		/// <summary>
		/// 是否存在该ID记录
		/// </summary>
        /// <param name="$Type">$Description</param>
        /// <returns>bool:True/False</returns>
		public bool Exists(Int32 ID)
		{
			return dal.Exists(ID);
		}

		/// <summary>
		/// 是否存在该条件记录
		/// </summary>
        /// <param name="strWhere">Where条件</param>
        /// <returns>bool:True/False</returns>
		public bool Exists(string strWhere)
		{
			return dal.Exists(strWhere);
		}

        /// <summary>
        /// 获取数量
        /// </summary>
        /// <returns>总记录数</returns>
        public int Count()
        { 
            return dal.Count();
        }

        /// <summary>
        /// 根据条件获取数量
        /// </summary>
        /// <param name="strWhere">Where条件</param>
        /// <returns>记录数</returns>
        public int Count(string strWhere)
        { 
            return dal.Count(strWhere);
        }

		/// <summary>
		/// 增加一条数据
		/// </summary>
        /// <param name="model">SpaceCode实体对象</param>
        /// <returns>自动增长列</returns>
		public int Add(Model.SpaceCode model)
		{
			return dal.Add(model);
		}

		/// <summary>
		/// 更新一条数据
		/// </summary>
        /// <param name="model">SpaceCode实体对象</param>
        /// <param name="strWhere">Where条件</param>
        /// <returns>修改条数</returns>
		public int Update(Model.SpaceCode model,string strWhere)
		{
			return dal.Update(model,strWhere);
		}

		/// <summary>
		/// 删除一条数据
		/// </summary>
        /// <param name="Int32">主键</param>
        /// <returns>bool:True/False</returns>
		public bool Delete(Int32 ID)
		{
			return dal.Delete(ID);
		}
		/// <summary>
		/// 删除数据
		/// </summary>
        /// <param name="strWhere">Where条件</param>
        /// <returns>删除条数</returns>
		public int DeleteList(string strWhere)
		{
			return dal.DeleteList(strWhere);
		}

		/// <summary>
		/// 得到一个对象实体
		/// </summary>
		public Model.SpaceCode GetModel(Int32 ID)
		{
			return dal.GetModel(ID);
		}

        /// <summary>
		/// 得到一个对象实体
		/// </summary>
        /// <param name="strWhere">Where条件</param>
		public Model.SpaceCode GetModelBystrWhere(string strWhere)
		{
            return dal.GetModelBystrWhere(strWhere);
        }

		/// <summary>
		/// 获得数据列表
		/// </summary>
        /// <param name="strWhere">Where条件</param>
        /// <returns>数据集</returns>
		public DataSet GetList(string strWhere)
		{
			return dal.GetList(strWhere);
		}
		/// <summary>
		/// 获得前几行数据
		/// </summary>
        /// <param name="Top">条数</param>
        /// <param name="strWhere">Where条件</param>
        /// <param name="filedOrder">filedOrder排序</param>
        /// <returns>数据集</returns>
		public DataSet GetList(int Top,string strWhere,string filedOrder)
		{
			return dal.GetList(Top,strWhere,filedOrder);
		}
		/// <summary>
		/// 获得数据列表
		/// </summary>
		public List<Model.SpaceCode> GetModelList(string strWhere)
		{
			DataSet ds = dal.GetList(strWhere);
			return DataTableToList(ds.Tables[0]);
		}
		/// <summary>
		/// 获得数据列表
		/// </summary>
		public List<Model.SpaceCode> DataTableToList(DataTable dt)
		{
			List<Model.SpaceCode> modelList = new List<Model.SpaceCode>();
			int rowsCount = dt.Rows.Count;
			if (rowsCount > 0)
			{
				Model.SpaceCode model;
				for (int n = 0; n < rowsCount; n++)
				{
					model = new Model.SpaceCode();
					if(dt.Rows[n]["ID"].ToString()!="")
				    {
                        model.ID=int.Parse(dt.Rows[n]["ID"].ToString());
				    }
                    if(dt.Rows[n]["UserID"].ToString()!="")
				    {
                        model.UserID=int.Parse(dt.Rows[n]["UserID"].ToString());
				    }
                    if(dt.Rows[n]["Classification"].ToString()!="")
				    {
                        model.Classification=dt.Rows[n]["Classification"].ToString();
				    }
                    if(dt.Rows[n]["Content"].ToString()!="")
				    {
                        model.Content=dt.Rows[n]["Content"].ToString();
				    }
                    if(dt.Rows[n]["UpNum"].ToString()!="")
				    {
                        model.UpNum=int.Parse(dt.Rows[n]["UpNum"].ToString());
				    }
                    if(dt.Rows[n]["DownNum"].ToString()!="")
				    {
                        model.DownNum=int.Parse(dt.Rows[n]["DownNum"].ToString());
				    }
                    if(dt.Rows[n]["AddTime"].ToString()!="")
				    {
                        model.AddTime=DateTime.Parse(dt.Rows[n]["AddTime"].ToString());
				    }
                    if(dt.Rows[n]["Lang"].ToString()!="")
				    {
                        model.Lang=dt.Rows[n]["Lang"].ToString();
				    }
                    modelList.Add(model);
				}
			}
			return modelList;
		}

		/// <summary>
		/// 获得数据列表
		/// </summary>
		public DataSet GetAllList()
		{
			return GetList("");
		}

		/// <summary>
		/// 分页获取数据列表
		/// </summary>
		public Model.PageData GetList(int PageSize,int PageIndex,string strWhere,string sort)
		{
			return dal.GetList(PageSize,PageIndex,strWhere,sort);
		}

		#endregion  Method
	}
}

